import 'package:flutter/material.dart';

class AnimationLogo extends AnimatedWidget {
  AnimationLogo({Key key,Animation<double> animation})
  :super(key:key,listenable:animation);

  @override
  Widget build(BuildContext context) {
    final Animation<double> animtation = listenable;
    return Positioned(
      child: FlutterLogo(size: 30,),
      top: animtation.value,
      left: 100,
    );
  }
}

class AnimationWidgetDemo extends StatefulWidget{
  @override
  _AnimationWidgetDemoState createState() => _AnimationWidgetDemoState();
}

class _AnimationWidgetDemoState extends State<AnimationWidgetDemo> with SingleTickerProviderStateMixin {
  Animation<double> animation;
  AnimationController controller;

  @override
  void initState() {
    // TODO: implement initState
      super.initState();
      controller = AnimationController(duration: Duration(milliseconds: 3000),vsync: this);
//      animation = CurvedAnimation(parent: controller,curve: Curves.fastLinearToSlowEaseIn);
      animation = Tween<double>(begin: 0,end: 300).animate(CurveTween(curve: Curves.linear).animate(controller));
      controller.forward();
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('动画组件'),
      ),
      body: new Builder(builder: (BuildContext cotntext){
        return Container(
          child: Stack(
            children: <Widget>[
              AnimationLogo(animation: animation,),
            ],
          ),
        );
      },),
    );
  }
}
